package com.wantup.dubbo.mock;

import com.wantup.dubbo.service.ServiceApi;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Scanner;
import java.util.concurrent.ExecutionException;

/**
 * Hello world!
 *
 * 本地存根  --> 希望 有些逻辑 直接在 客户端 调用端 执行 在给后台。
 *
 */
public class MockConsumerApp {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //System.out.println( "ConsumerApp --> Hello World!" );
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-mock-consumer.xml");
        context.start();//创建容器 读取配置文件

        while (true) {
            Scanner scanner = new Scanner(System.in);
            String msg = scanner.next();

            //获取接口
            ServiceApi serviceApi = (ServiceApi) context.getBean("consumerService");
            String s = serviceApi.sendMsg(msg);
            System.out.println(" 收到的响应 s --> " + s);

        }

    }
}
